//
//  FaceDiscernHistoryTableViewCell.m
//  NuwaRobot
//
//  Created by Kendama on 2017/12/1.
//  Copyright © 2017年 Kendama. All rights reserved.
//

#import "FaceDiscernHistoryTableViewCell.h"

NSString *const kFaceDiscernHistoryTableViewCellIdentifier = @"kFaceDiscernHistoryTableViewCellIdentifier";

@implementation FaceDiscernHistoryTableViewCell

+ (instancetype)dequeueReusableWithTableView:(UITableView *)tableView
{
    FaceDiscernHistoryTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:kFaceDiscernHistoryTableViewCellIdentifier];
    if (cell == nil)
    {
        cell = [[FaceDiscernHistoryTableViewCell alloc]init];
    }
    return cell;
}

- (instancetype)init
{
    self = [super initWithStyle:UITableViewCellStyleDefault reuseIdentifier:kFaceDiscernHistoryTableViewCellIdentifier];
    if (self)
    {
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        self.backgroundColor = cellBackgroundColor;
        [self masLayoutSubview];
    }
    return self;
}

- (UIImageView *)avatarImageView
{
    if(!_avatarImageView)
    {
        UIView *superView = self.contentView;
        _avatarImageView = [[UIImageView alloc]init];
        [superView addSubview:_avatarImageView];
    }
    return _avatarImageView;
}
- (UILabel *)nameLabel
{
    if(!_nameLabel)
    {
        UIView *superView = self.contentView;
        _nameLabel = [[UILabel alloc]init];
        [superView addSubview:_nameLabel];
        [_nameLabel setFont:fontCommonSize];
        [_nameLabel setTextColor:[UIColor whiteColor]];
    }
    return _nameLabel;
}
- (UILabel *)dateLabel
{
    if(!_dateLabel)
    {
        UIView *superView = self.contentView;
        _dateLabel = [[UILabel alloc]init];
        [superView addSubview:_dateLabel];
        [_dateLabel setFont:fontWithSize(14)];
        [_dateLabel setTextColor:rgba(88,111,161,1)];
    }
    return _dateLabel;
}


- (UIImageView *)rightImageView
{
    if(!_rightImageView)
    {
        UIView *superView = self.contentView;
        _rightImageView = [[UIImageView alloc]init];
        [superView addSubview:_rightImageView];
        _rightImageView.image = [UIImage imageNamed:@"enter"];
    }
    return _rightImageView;
}

- (void)masLayoutSubview
{
    __weak UIView *superView = self.contentView;
    
    [self.avatarImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(superView.mas_centerY);
        make.left.mas_equalTo(superView.mas_left).with.offset(px1080Width(40));
        make.height.width.mas_equalTo(px1920Height(140));
    }];
    
    [self.rightImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(superView.mas_centerY);
        make.right.mas_equalTo(superView.mas_right).with.offset(-px1920Height(40));
        make.height.mas_equalTo(px1920Height(35));
        make.width.mas_equalTo(px1920Height(20));
    }];
    
    [self.nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self.avatarImageView.mas_right).with.offset(px1080Width(40));
        make.bottom.mas_equalTo(superView.mas_centerY).with.offset(-px1920Height(20));
    }];
    
    [self.dateLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self.avatarImageView.mas_right).with.offset(px1080Width(40));
        make.top.mas_equalTo(superView.mas_centerY).with.offset(px1920Height(20));
    }];
}

@end
